package com.qianyu.project.service.impl;

import com.qianyu.project.core.annotation.FlowBegin;
import com.qianyu.project.core.annotation.FlowEntry;
import com.qianyu.project.entity.MaterialRefoundRecord;
import com.qianyu.project.entity.MaterialRefountRecordDetail;
import com.qianyu.project.mapper.MaterialRefoundRecordMapper;
import com.qianyu.project.service.IMaterialRefoundRecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qianyu.project.service.IMaterialRefountRecordDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 材料退库记录表 服务实现类
 * </p>
 *
 * @author gs
 * @since 2021-01-30
 */
@Service
public class MaterialRefoundRecordServiceImpl extends ServiceImpl<MaterialRefoundRecordMapper, MaterialRefoundRecord> implements IMaterialRefoundRecordService {
    @Autowired
    private MaterialRefoundRecordMapper mapper;
    @Autowired
    private IMaterialRefountRecordDetailService service;

    @Override
    @FlowBegin("material_refound_record")
    public void saveRefoundRecord(@FlowEntry("id") MaterialRefoundRecord record, List<MaterialRefountRecordDetail> detailList) {
        mapper.insert(record);
        detailList.forEach(d->{
            d.setInstorageId(record.getId());
        });
    }
}
